﻿using CHSystemApi.Framework.Middleware;
using Microsoft.AspNetCore.Builder;

namespace CHSystemApi.Framework
{
    public static class UseMiddleware
    {
        public static IApplicationBuilder UseMiddleWare<TMiddleware>(this IApplicationBuilder app) where TMiddleware : IMiddleware
        {
            app.UseMiddleware<TMiddleware>();
            return app;
        }

        /// <summary>
        /// 异常处理中间件
        /// </summary>
        /// <param name="app"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseException(this IApplicationBuilder app)
        {
            return app.UseMiddleWare<ExceptionMiddleware>();
        }

        /// <summary>
        /// 登录信息解析中间件
        /// </summary>
        /// <param name="app"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseLoginInfo(this IApplicationBuilder app)
        {
            return app.UseMiddleWare<LoginInfoMiddleware>();
        }
    }
}
